import { IPSAppCodeList } from '../../app/codelist/ipsapp-code-list';
import { PSEditorImpl } from '../pseditor-impl';
import { IPSCodeListEditor } from './ipscode-list-editor';

export class PSCodeListEditorImpl extends PSEditorImpl implements IPSCodeListEditor {
  protected psappcodelist: IPSAppCodeList | null = null;

  getPSAppCodeList(): IPSAppCodeList | null {
    if (this.psappcodelist != null) return this.psappcodelist;
    const value = this.M.getPSAppCodeList;
    if (value == null) {
      return null;
    }
    this.psappcodelist = this.getPSModel4('app.codelist.IPSAppCodeList', value, 'getPSAppCodeList') as IPSAppCodeList;
    return this.psappcodelist;
  }

  get psAppCodeList(): IPSAppCodeList | null {
    return this.getPSAppCodeList();
  }

  getPSAppCodeListMust(): IPSAppCodeList {
    const value = this.getPSAppCodeList();
    if (value == null) {
      throw new Error('未指定应用代码表对象');
    }
    return value;
  }

  get array(): boolean {
    return this.M.array != null ? this.M.array : false;
  }

  get cls(): string {
    return 'PSCodeListEditorImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.editor.IPSCodeListEditor') return true;
    return super.instanceof(cls);
  }
}
